package com.retail.bbq.cola.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;

/**
 * @author : jie.zhou
 * @date : 2025/7/24
 */
@Getter
@AllArgsConstructor
public enum TicketStatusEnum {

    FAIL(0, "未领券"),
    SUCC(1, "领券成功"),

    ;

    private final int code;
    private final String desc;

    private static final Map<Integer, TicketStatusEnum> codeMap = new HashMap<>();
    private static final Map<String, TicketStatusEnum> descMap = new HashMap<>();

    static {
        Arrays.stream(TicketStatusEnum.values())
                .forEach(val -> {
                    codeMap.put(val.getCode(), val);
                    descMap.put(val.getDesc(), val);
                });
    }

    public static TicketStatusEnum getEnumByCode(Integer code) {
        return codeMap.get(code);
    }

    public static TicketStatusEnum getEnumByDesc(String desc) {
        return descMap.get(desc);
    }

}
